import React from 'react';
import { Descriptions, Col, Row } from "antd";

export default class OrderStep extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      memberInfo: props.memberInfo, //数据信息
    }
  }
  async componentDidMount() {
    await this.getData()
  }
  // 数据处理
  getData = async () => {
    let { memberInfo } = this.state
    if (memberInfo) {
      let payWay = ''
      switch (memberInfo.payWay) {
        case 'WeChat':
          payWay = '微信'
          break;
        case 'Alipay':
          payWay = '支付宝'
          break;
        case 'UnionPay':
          payWay = "银联"
          break;
        case 'YsPay':
          payWay = "银行卡"
          break;
        default:
          payWay = "-"
      }
      var reg = /^(\d{3})\d{4}(\d{4})$/;
      memberInfo.memberName = memberInfo.memberName[0] +  "*".repeat(memberInfo.memberName.length - 1 );
      memberInfo.memberPhone = memberInfo.memberPhone.toString().replace(reg, '$1****$2');
      memberInfo.orderPayPrice = memberInfo.orderPayPrice ? '￥' + React.$transNum(memberInfo.orderPayPrice, 2, -2) : '￥0.00'
      memberInfo.orderSalesReturnPrice = memberInfo.orderSalesReturnPrice ? '￥' + React.$transNum(memberInfo.orderSalesReturnPrice, 2, -2) : '￥0.00'
      memberInfo.practicalStorePrice = memberInfo.practicalStorePrice ? '￥' + React.$transNum(memberInfo.practicalStorePrice, 2, -2) : '￥0.00'
      memberInfo.practicalCommission = memberInfo.practicalCommission ? '￥' + React.$transNum(memberInfo.practicalCommission, 2, -2) : '￥0.00'
      memberInfo.payWay = payWay
      this.setState({
        memberInfo,
      })
    }
  }
  render() {
    const { memberInfo } = this.state
    return (
      <div>
        <Descriptions layout="vertical" bordered column={4}>
          <Descriptions.Item label="收货人信息">
            <Row>
              <Col>收货人:</Col>
              <Col>{memberInfo.memberName}</Col>
            </Row>
            <Row>
              <Col>联系电话:</Col>
              <Col>{memberInfo.memberPhone}</Col>
            </Row>
            <Row>
              <Col>收货地址:</Col>
              <Col>{memberInfo.memberAddress}</Col>
            </Row>
          </Descriptions.Item>
          <Descriptions.Item label="付款信息">
            <Row>
              <Col>实付金额</Col>
              <Col>{memberInfo.orderPayPrice}</Col>
            </Row>
            <Row>
              <Col>付款方式:</Col>
              <Col>{memberInfo.payWay}</Col>
            </Row>
            <Row>
              <Col>付款时间:</Col>
              <Col>{memberInfo.payTime}</Col>
            </Row>
          </Descriptions.Item>
          <Descriptions.Item label="买家信息">
            <Row>
              <Col>买家ID:</Col>
              <Col>{memberInfo.memberId}</Col>
            </Row>
            <Row>
              <Col>买家昵称:</Col>
              <Col>{memberInfo.buyerName}</Col>
            </Row>
          </Descriptions.Item>
        </Descriptions>

      </div>
    )
  }
}
